<?php


namespace app\task;


class DemoTask
{

    function act($pid,$taskId)
    {
        $dateFormat = "Y-m-d H:i:s";
        $output = "[%datetime%] %channel%.%level_name%: %message% %context%\n"; // 输出格式
        $formatter = new \Monolog\Formatter\LineFormatter($output, $dateFormat);
        $stream = new \Monolog\Handler\StreamHandler(__DIR__.'/task.log', \Monolog\Logger::DEBUG);
        $stream->setFormatter($formatter);
        $logger = new \Monolog\Logger('task');
        $logger->pushHandler($stream);
        $logger->debug("$pid start to do task {$taskId} is over");
    }
}